/******************渲染数据**************/
//获取数据
 var aid=GetQueryString('aid')
 var type=GetQueryString('type')
 switch (type){
 	case 'psyer':
 	    getstorageByPsy()
 		break;
    case 'protector':
        getstorageByPro()
        break;
 	default:
 	    getstorage()
 		break;
 }
 function getstorage(){
     var schedule= JSON.parse(localStorage.getItem('scheduleOne'))
     if(schedule && schedule.apply.apply_id==aid){
         var caseData=schedule.case_msg
         var replyData
         if(schedule.apply.status=='已回复'){
            replyData=schedule.reply
         }else{
             replyData=''
         }
         setScheduleCase(caseData,replyData)
     }else{
         window.history.back()
     }
 }
 function getstorageByPsy(){
     var schedule= JSON.parse(localStorage.getItem('scheduleOne'))
     if(schedule && schedule.appoint.id==aid){
         var caseData=schedule.case
         var replyData=schedule.record
         setScheduleCaseByPsy(caseData,replyData)
     }else{
         window.history.back()
     }
 }
 function getstorageByPro(){
     var schedule= JSON.parse(localStorage.getItem('scheduleOne'))
     if(schedule){
         var caseData=schedule.case_msg
         var replyData=schedule.record_list
         setScheduleCaseByPro(caseData,replyData)
     }else{
         window.history.back()
     }
 }

    //渲染数据
   function setScheduleCase(caseData,replyData){
       var html1,html2,html3
        html1=`
            <p class="smTitle"><label for="">●</label>案件基本信息<label for="">●</label></p>
            <p class="caseBox"><span>案件编号：</span><label for="">${caseData.num}</label></p>
            <p class="caseBox"><span>嫌疑人编号：</span><label for="">${caseData.crime}</label></p>
            <p class="caseBox"><span>案件创立时间：</span><label for="">${caseData.create_time}</label></p>
            <p class="caseBox"><span>案件当前状态：</span><label for="">${caseData.case_status}</label></p>
        `
        html2=`
            <p class="smTitle"><label for="">●</label>案件描述<label for="">●</label></p>
            <p class="caseBox">${caseData.case_describe}</p>
                    
        `
        html3=`<p class="smTitle"><label for="">●</label>处理详情<label for="">●</label></p>`
        if(replyData){
            $.each(replyData,function(k,v){
                if(v.appointed_user&&v.appointed_user.length>0){
                    var sendnames=[]
                    $.each(v.appointed_user,function(k2,v2){
                        var val=`${v2.name}(${v2.tel})`
                        sendnames.push(val)
                    })
                    var sendpeople=sendnames.join('、')
                     html3+=`<p class="caseBox"><span style="color:orange">${v.answerer_name}</span>指派给了<span style="color:red">${sendpeople}</span></p>`
                }else{
                    html3+=`<p class="caseBox"><span style="color:orange">${v.answerer_name}</span>回复:${v.content}</p>`
                }
            })
        }else{
            html3+=`<p class="caseBox">暂无回复</p>`
        }
        $('.base').html(html1)
        $('.desc').html(html2)
        $('.reply').html(html3)
   }
   function setScheduleCaseByPsy(caseData,replyData){
       var html1,html2,html3
        html1=`
            <p class="smTitle"><label for="">●</label>案件基本信息<label for="">●</label></p>
            <p class="caseBox"><span>案件编号：</span><label for="">${caseData.case_num}</label></p>
            <p class="caseBox"><span>嫌疑人编号：</span><label for="">${caseData.num}</label></p>
            <p class="caseBox"><span>案件创立时间：</span><label for="">${timeDate(caseData.create_time*1000)}</label></p>
        `
        html2=`
            <p class="smTitle"><label for="">●</label>案件描述<label for="">●</label></p>
            <p class="caseBox">${caseData.case_describe}</p>
                    
        `
         html3=`
            <p class="smTitle"><label for="">●</label>回复详情<label for="">●</label></p>
        `
        if(replyData.length==0){
             html3+=`<p class="caseBox">暂无回复</p>`
        }
        $.each(replyData,function(k,v){
            html3+=`<p class="caseBox"><span style="color:orange">${v.answerer}</span>回复:${v.reply}</p>`
        })
        $('.base').html(html1)
        $('.desc').html(html2)
        $('.reply').html(html3)
   }
/******************渲染数据end**************/
function setScheduleCaseByPro(caseData,replyData){
       var html1,html2,html3
        html1=`
            <p class="smTitle"><label for="">●</label>案件基本信息<label for="">●</label></p>
            <p class="caseBox"><span>嫌疑人编号：</span><label for="">${caseData.num}</label></p>
            <p class="caseBox"><span>案件状态：</span><label for="">${caseData.case_status}</label></p>
            <p class="caseBox"><span>案件创立时间：</span><label for="">${caseData.create_time}</label></p>
            <p class="caseBox"><span>案件发生时间：</span><label for="">${caseData.case_time}</label></p>
        `
        html2=`
            <p class="smTitle"><label for="">●</label>案件描述<label for="">●</label></p>
            <p class="caseBox">${caseData.case_describe}</p>
                    
        `
        html3=`
            <p class="smTitle"><label for="">●</label>回复详情<label for="">●</label></p>
            <ul class="mui-table-view" style="top:-5px"> 
        `
        $.each(replyData,function(k,v){
            var type_ch
            switch (v.type){
                case 'record':
                   type_ch='观护记录'
                    break;
                case 'evaluate':
                   type_ch='综合考评'
                    break;
                case 'labour':
                   type_ch='劳动改造'
                    break;
                case 'thought':
                   type_ch='思想汇报'
                    break;
                default:
                    break;
            }
            html3+=`
                <li class="mui-table-view-cell mui-collapse">
                    <a class="mui-navigate-right" href="#">${type_ch}</a>
                    <div class="mui-collapse-content">
                `
            if(v.list.length==0){
                html3+=`<p>暂无回复</p>`
            }else{
                $.each(v.list,function(k2,v2){
                     html3+=`<p><span style="color:orange">${v2.answerer_name}</span>回复:${v2.content}</p>`
                })
            }
            html3+=`</div></li>`
        })
        html3+=`</ul>`
        $('.base').html(html1)
        $('.desc').html(html2)
        $('.reply').html(html3)
   }
/******************渲染数据end**************/


